package singleton;

import thread.ThreadUtils;

public class VolatileLazySingleton {

    private static volatile VolatileLazySingleton uniqueInstance;

    private VolatileLazySingleton() {
    }

    public static VolatileLazySingleton getInstance() {
        if (uniqueInstance == null) {
            ThreadUtils.sleep(100); //模拟耗时操作
            uniqueInstance = new VolatileLazySingleton();
        }
        return uniqueInstance;
    }
}
